package com.ddzh.consumer.web;

import com.ddzh.clients.UserFeignApi;
import com.ddzh.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.Map;

@RestController
@RequestMapping("feign")
@Slf4j
public class FeignController {

    @Autowired
    private UserFeignApi userFeignApi;//feign提供负载均衡，不需要将服务注册到Erueka
  
    @GetMapping("{id}")
    public User queryById(@PathVariable("id") String username){
        User user = userFeignApi.queryById(username);
        System.out.println("user = " + user);
        return user;
    }
}